package com.wenju.liebiaodaojishi;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private TimeDownLvAdapter mAdapter;
    private RecyclerView mListView;
    private List<TimeDownItem> lstTimeDownItems;
    private EditText wEts;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        wEts = findViewById(R.id.et_s);
        mListView= findViewById(R.id.rv);
        mListView.setLayoutManager(new LinearLayoutManager(this));
        setAdapter();
    }

    /**
     * 设置适配器
     * */
    private void setAdapter() {
        getTimerItemList();
        mAdapter = new TimeDownLvAdapter(this,lstTimeDownItems);
        mListView.setAdapter(mAdapter);
    }

    /**
     * 设置倒计时的数据
     * */
    public void getTimerItemList() {
        lstTimeDownItems = new ArrayList<>();
        lstTimeDownItems.add(new TimeDownItem("商品", 60));
        lstTimeDownItems.add(new TimeDownItem("商品", 120));
        lstTimeDownItems.add(new TimeDownItem("商品", 120));
    }

    public void addList(View view){
//        lstTimeDownItems.add(new TimeDownItem("商品", Long.parseLong(wEts.getText().toString())));
        lstTimeDownItems.add(new TimeDownItem("商品", 60));
        mAdapter.notifyDataSetChanged();
    }
}